/* 异常的多态 */
#include <iostream>

using namespace std;

class Base
{
public:
    virtual void print(void) = 0;
};

class OutRange:public Base
{
public:
    virtual void print(void)
    {
        cout << "out range" << endl;
    }
};

class NullPtr:public Base
{
public:
    virtual void print(void)
    {
        cout << "NullPtr" << endl;
    }
};

int main(int argc, char **argv)
{

    try 
    {
        //throw OutRange();
        throw NullPtr();
    }
    catch (Base &ob)
    {
        ob.print();
    }

    return 0;
}
